package com.sima.crawler;

import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.monitor.SpiderMonitor;
import us.codecraft.webmagic.pipeline.ConsolePipeline;

import javax.management.JMException;

/**
 * Created by cfq on 2017/4/30.
 */
public class MonitorTest {

    public static void main(String[] args) {

        Spider spider = Spider.create(new GankRepoPageProcessor())
                .addUrl("http://gank.io")
                .addPipeline(new ConsolePipeline())
                .thread(5);
        try {
            SpiderMonitor.instance().register(spider);

        } catch (JMException e) {
            e.printStackTrace();
        }

        spider.start();


    }
}
